package com.gjun.struts.bean;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.gjun.struts.bean.ext.Book;
import com.gjun.struts.bean.ext.Category;

public class BookJsonBean {
	
	private Integer id;

	private String author;

	private String publishing;

	private long publishTime;
	
	private String publishTime_str;

	private String wordNumber;

	private String whichEdtion;

	private String totalPage;

	private Integer printTime;
	
	private String printTime_str;

	private String printNumber;

	private String isbn;

	private String authorSummary;

	private String catalogue;
	
	
	//product
	private String productName;

	private String description;

	private long addTime;

	private double fixedPrice;

	private double dangPrice;

	private String keywords;

	private Integer hasDeleted;

	private String productPic;
	
	/**
	 * @return the publishTime_str
	 */
	public String getPublishTime_str() {
		return publishTime_str;
	}

	/**
	 * @param publishTimeStr the publishTime_str to set
	 */
	public void setPublishTime_str(String publishTimeStr) {
		publishTime_str = publishTimeStr;
	}

	/**
	 * @return the printTime_str
	 */
	public String getPrintTime_str() {
		return printTime_str;
	}

	/**
	 * @param printTimeStr the printTime_str to set
	 */
	public void setPrintTime_str(String printTimeStr) {
		printTime_str = printTimeStr;
	}

	private Integer firstCategoryId;
	
	private String firstCategory;
	
	private Integer secondCategoryId;
	
	private String secondCategory;
	

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public long getAddTime() {
		return addTime;
	}

	public void setAddTime(long addTime) {
		this.addTime = addTime;
	}

	public double getFixedPrice() {
		return fixedPrice;
	}

	public void setFixedPrice(double fixedPrice) {
		this.fixedPrice = fixedPrice;
	}

	public double getDangPrice() {
		return dangPrice;
	}

	public void setDangPrice(double dangPrice) {
		this.dangPrice = dangPrice;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public Integer getHasDeleted() {
		return hasDeleted;
	}

	public void setHasDeleted(Integer hasDeleted) {
		this.hasDeleted = hasDeleted;
	}

	public String getProductPic() {
		return productPic;
	}

	public void setProductPic(String productPic) {
		this.productPic = productPic;
	}

	public Integer getFirstCategoryId() {
		return firstCategoryId;
	}

	public void setFirstCategoryId(Integer firstCategoryId) {
		this.firstCategoryId = firstCategoryId;
	}

	public String getFirstCategory() {
		return firstCategory;
	}

	public void setFirstCategory(String firstCategory) {
		this.firstCategory = firstCategory;
	}

	public Integer getSecondCategoryId() {
		return secondCategoryId;
	}

	public void setSecondCategoryId(Integer secondCategoryId) {
		this.secondCategoryId = secondCategoryId;
	}

	public String getSecondCategory() {
		return secondCategory;
	}

	public void setSecondCategory(String secondCategory) {
		this.secondCategory = secondCategory;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getPublishing() {
		return publishing;
	}

	public void setPublishing(String publishing) {
		this.publishing = publishing;
	}

	public long getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(long publishTime) {
		this.publishTime = publishTime;
	}

	public String getWordNumber() {
		return wordNumber;
	}

	public void setWordNumber(String wordNumber) {
		this.wordNumber = wordNumber;
	}

	public String getWhichEdtion() {
		return whichEdtion;
	}

	public void setWhichEdtion(String whichEdtion) {
		this.whichEdtion = whichEdtion;
	}

	public String getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(String totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getPrintTime() {
		return printTime;
	}

	public void setPrintTime(Integer printTime) {
		this.printTime = printTime;
	}

	public String getPrintNumber() {
		return printNumber;
	}

	public void setPrintNumber(String printNumber) {
		this.printNumber = printNumber;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getAuthorSummary() {
		return authorSummary;
	}

	public void setAuthorSummary(String authorSummary) {
		this.authorSummary = authorSummary;
	}

	public String getCatalogue() {
		return catalogue;
	}

	public void setCatalogue(String catalogue) {
		this.catalogue = catalogue;
	}

	public BookJsonBean(Book book) {
		super();
		this.id = book.getId();
		this.author = book.getAuthor();
		this.publishing = book.getPublishing();
		this.publishTime = book.getPublishTime();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD");
		publishTime_str = sdf.format(new Date(publishTime));
		
		this.wordNumber = book.getWordNumber();
		this.whichEdtion = book.getWhichEdtion();
		this.totalPage = book.getTotalPage();
		this.printTime = book.getPrintTime();
		printTime_str = sdf.format(new Date(printTime));
		this.printNumber = book.getPrintNumber();
		this.isbn = book.getIsbn();
		this.authorSummary = book.getAuthorSummary();
		this.catalogue = book.getCatalogue();
		
		//product
		this.productName = book.getProductName();
		this.description = book.getDescription();
		this.addTime = book.getAddTime();
		this.fixedPrice = book.getFixedPrice();
		this.dangPrice = book.getDangPrice();
		this.keywords = book.getKeywords();
		this.hasDeleted = book.getHasDeleted();
		this.productPic = book.getProductPic();
		for (Category category : book.getCats()) {
			if(category.getParentId() == 0){
				this.firstCategoryId = category.getId();
				this.firstCategory = category.getName();
			} else{
				this.secondCategoryId = category.getId();
				this.secondCategory = category.getName();
			}
		}
		
	}
	
	

}
